function CSAdd(left,right) {
	BaseProtocal.call(this);
	this.type = protocalTypes.CS_ADD;
	this.param = [parseInt(left),parseInt(right)];
	if(this.param[0] == null || isNaN(this.param[0])) {
		this.param[0] = 0;
	}
	if(this.param[1] == null || isNaN(this.param[1])) {
		this.param[1] = 0;
	}
}
CSAdd.prototype = new BaseProtocal();
CSAdd.prototype.constructor = CSAdd;
CSAdd.prototype.write = function() {
	return this.param;
}

function SCAdd() {
	BaseProtocal.call(this);
	this.type = protocalTypes.SCAdd;
	this.result;
}
SCAdd.prototype = new BaseProtocal();
SCAdd.prototype.constructor = SCAdd;
SCAdd.prototype.read = function(data) {
	this.result = data;
}
function AddMessageHandler() {
	BaseHandler.call(this);
}
AddMessageHandler.prototype = new AddMessageHandler();
AddMessageHandler.prototype.constructor = AddMessageHandler;
AddMessageHandler.prototype.process = function(protocal) {
	$('#add_result').val(protocal.result);
}

function CSSub(left,right) {
	BaseProtocal.call(this);
	this.type = protocalTypes.CS_SUB;
	this.param = [parseInt(left),parseInt(right)];
	if(this.param[0] == null || isNaN(this.param[0])) {
		this.param[0] = 0;
	}
	if(this.param[1] == null || isNaN(this.param[1])) {
		this.param[1] = 0;
	}
}
CSSub.prototype = new BaseProtocal();
CSSub.prototype.constructor = CSSub;
CSSub.prototype.write = function() {
	return this.param;
}

function SCSub() {
	BaseProtocal.call(this);
	this.type = protocalTypes.SCSub;
	this.result;
}
SCSub.prototype = new BaseProtocal();
SCSub.prototype.constructor = CSSub;
SCSub.prototype.read = function(data) {
	this.result = data;
}
function SubMessageHandler() {
	BaseHandler.call(this);
}
SubMessageHandler.prototype = new SubMessageHandler();
SubMessageHandler.prototype.constructor = SubMessageHandler;
SubMessageHandler.prototype.process = function(protocal) {
	$('#sub_result').val(protocal.result);
}

function CSMul(left,right) {
	BaseProtocal.call(this);
	this.type = protocalTypes.CS_MUL;
	this.param = [parseInt(left),parseInt(right)];
	if(this.param[0] == null || isNaN(this.param[0])) {
		this.param[0] = 0;
	}
	if(this.param[1] == null || isNaN(this.param[1])) {
		this.param[1] = 0;
	}
}
CSMul.prototype = new BaseProtocal();
CSMul.prototype.constructor = CSMul;
CSMul.prototype.write = function() {
	return this.param;
}

function SCMul() {
	BaseProtocal.call(this);
	this.type = protocalTypes.SCMul;
	this.result;
}
SCMul.prototype = new BaseProtocal();
SCMul.prototype.constructor = CSMul;
SCMul.prototype.read = function(data) {
	this.result = data;
}
function MulMessageHandler() {
	BaseHandler.call(this);
}
MulMessageHandler.prototype = new MulMessageHandler();
MulMessageHandler.prototype.constructor = MulMessageHandler;
MulMessageHandler.prototype.process = function(protocal) {
	$('#mul_result').val(protocal.result);
}

function CSDiv(left,right) {
	BaseProtocal.call(this);
	this.type = protocalTypes.CS_DIV;
	this.param = [parseInt(left),parseInt(right)];
	if(this.param[0] == null || isNaN(this.param[0])) {
		this.param[0] = 0;
	}
	if(this.param[1] == null || isNaN(this.param[1])) {
		this.param[1] = 0;
	}
}
CSDiv.prototype = new BaseProtocal();
CSDiv.prototype.constructor = CSDiv;
CSDiv.prototype.write = function() {
	return this.param;
}

function SCDiv() {
	BaseProtocal.call(this);
	this.type = protocalTypes.SCDiv;
	this.result;
}
SCDiv.prototype = new BaseProtocal();
SCDiv.prototype.constructor = CSDiv;
SCDiv.prototype.read = function(data) {
	this.result = data;
}
function DivMessageHandler() {
	BaseHandler.call(this);
}
DivMessageHandler.prototype = new DivMessageHandler();
DivMessageHandler.prototype.constructor = DivMessageHandler;
DivMessageHandler.prototype.process = function(protocal) {
	$('#div_result').val(protocal.result);
}

function initHandler(handler) {
	handler.register(protocalTypes.SC_ADD,SCAdd,new AddMessageHandler());
	handler.register(protocalTypes.SC_SUB,SCSub,new SubMessageHandler());
	handler.register(protocalTypes.SC_MUL,SCSub,new MulMessageHandler());
	handler.register(protocalTypes.SC_DIV,SCSub,new DivMessageHandler());
}